//
//  LSSystemConfig.m
//  听说弱点强化训练
//
//  Created by 盛超 on 2018/9/13.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "LSSystemConfig.h"
#import "LSSyetemInfoManager.h"

@implementation LSSystemConfig

+ (instancetype)config
{
    static LSSystemConfig *systemConfig = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        systemConfig = [[LSSystemConfig alloc] init];
        
        LSSyetemInfoManager *manager = [[LSSyetemInfoManager alloc] init];
        [manager requestWithCompltionSuccess:^(LSModelSystem *model) {
            
            for(LSScoreLevelConfig *score in model.ModelScoreLevelConfigList)
            {

                switch (score.ModuleID) {
                    case 2:
                        systemConfig.listenScore = score.ScoreLevel;
                        break;
                    case 3:
                      
                        break;
                    case 4:
                        systemConfig.pronounceScore = score.ScoreLevel;
                        break;
                    case 5:
                        systemConfig.readScore = score.ScoreLevel;
                        break;
                    case 6:
                        systemConfig.vocabularyScore = score.ScoreLevel;
                        break;
                        
                    default:
                        break;
                }
                
            }
            for (LSAudioSpeech * audioSpeech in model.ModelAudioSpeechList) {
                if ([audioSpeech.SpeechName isEqualToString:@"慢速"]) {
                    systemConfig.lowSpeed = (1.00*audioSpeech.SentenceNum)/(1.00*audioSpeech.SpeechTime);
                    
                } else if ([audioSpeech.SpeechName isEqualToString:@"中速"]) {
                    systemConfig.normalSpeed = (1.00*audioSpeech.SentenceNum)/(1.00*audioSpeech.SpeechTime);
                    
                } else {
                     systemConfig.highSpeed = (1.00*audioSpeech.SentenceNum)/(1.00*audioSpeech.SpeechTime);
                }
            }

            
        } failuer:^(NSString *error) {
            systemConfig.listenScore = 100;
            systemConfig.pronounceScore = 80;
            systemConfig.readScore = 80;
            systemConfig.vocabularyScore = 80;
            systemConfig.lowSpeed = 110.00/100.00;
            systemConfig.normalSpeed = 110.00/90.00;
            systemConfig.highSpeed = 110.00/80.00;
        }];
        
    });
    return systemConfig;
}


@end
